package com.chongyuan.producer.mq;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.SendResult;
import com.aliyun.openservices.ons.api.bean.ProducerBean;

@Service
public class OrderProducerService {
    @Resource(name="producer")
    private ProducerBean producer;
    @Value("${MQ.Topic}")
    private String topic;
    
    private final static String DEVICE_GPS_TAG = "GPSTAG";
    
    public SendResult sendMessage(String msg){
        Message message = new Message(topic, DEVICE_GPS_TAG, "MID_" + System.currentTimeMillis(), msg.getBytes());
        return producer.send(message);
    }
}
